local cjson = require 'cjson.safe';

local file = io.open('./conf/data.json', 'r');

if  not file then
    ngx.log(ngx.ERR, 'http system failed to load data file.')
    return ngx.exit()
end

local content = file:read('*all')

local data = cjson.decode(content);

local proxyArr = ngx.shared.proxies

local index = 0
for i,v in pairs(data) do
    if v.type == '0' then
        proxyArr:set(i, v.value);
        index = index + 1
    end
end

ngx.log(ngx.INFO, 'http system loaded rules:', index);

file:close()